package cn.jsc.controller;

import cn.jsc.entity.UploadVO;
import cn.jsc.result.JSONResult;
import cn.jsc.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileService fileService;

    /**
     *  文件上传
     */
    @PostMapping("/uploadFile")
    public JSONResult uploadImg(@RequestParam("fileName") MultipartFile multipartFile){
        return fileService.uploadImg(multipartFile);
    }

    /**
     * 文件删除
     */
    @PostMapping("/deleteFile")
    public JSONResult deleteFile(@RequestBody UploadVO vo){
        return fileService.deleteFile(vo.getOssKey());
    }
}
